#ifndef		__SINGLETON_H_INCLUDED__
#define		__SINGLETON_H_INCLUDED__

#include	<memory>

/**
 * Singleton model.
 */
template<class O>
class Singleton {
public:
	Singleton() {}

	/**
	 * Get runtime singleton instance of class O
	 */
	static O & Instance() {
		if (!_ins) _ins.reset(new O);
		return *_ins;
	}

	/**
	 * Release runtime singleton instance manually.
	 */
	static void Release() {
		_ins.reset(nullptr);
	}

private:
	static std::unique_ptr<O> _ins;
};

template<class O> std::unique_ptr<O> Singleton<O>::_ins;

#endif//!	__SINGLETON_H_INCLUDED__